package com.ecpss;

import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) throws Exception {
//        String regularExpression = "(^[+-]?[0-9]+)|(^[+-]?[0-9]+\\.[0-9]+)";
//        boolean strResult0 = "-x123".matches(regularExpression);  //运行结果：true
//        boolean strResult1 = "123.01".matches(regularExpression);  //运行结果：true
//        boolean strResult2 = "011.0".matches(regularExpression);  //运行结果：true
//        boolean strResult3 = "00.11".matches(regularExpression);  //运行结果：true
//        boolean strResult4 = "00.11a".matches(regularExpression);  //运行结果：false
//        boolean strResult5 = "Hello May".matches(regularExpression);  //运行结果：false
//        System.out.println(strResult0);
//        System.out.println(strResult1);
//        System.out.println(strResult2);
//        System.out.println(strResult3);
//        System.out.println(strResult4);
//        System.out.println(strResult5);
//        Pattern pattern = Pattern.compile(regularExpression);
//        Matcher matcher = pattern.matcher("x1");
//        System.out.println(matcher.find());
        Pattern pattern=Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$");
        // 判断小数点后2位的数字的正则表达式

        System.out.println( pattern.matcher("str").matches());
        System.out.println( pattern.matcher("1").matches());
        System.out.println( pattern.matcher("11.21").matches());
        System.out.println( pattern.matcher("121.212").matches());
        System.out.println( pattern.matcher("121s.21").matches());
        System.out.println( pattern.matcher("s121.21").matches());
        System.out.println( pattern.matcher("121.2x").matches());
        System.out.println( pattern.matcher("121.22s").matches());


    }
}
